<template>
    <Modal v-model="visible" title="查验异常信息处理" width="1200" :key="key" style="position:relative;"
           :mask-closable="false">
        <div>
            <Form :label-width="150" inline>
                <Form-item label="姓名:">
                    <Input v-model="queryParam.azcp0003" placeholder="" class="itemShortStyle"/>
                </Form-item>
                <Form-item label="证件号码:">
                    <Input v-model="queryParam.azcp0001" placeholder="" class="itemShortStyle"/>
                </Form-item>
                <Form-item label="异常类型:">
                    <dictSelect :sel_val='queryParam.pshr0001' dictCode="warningcategory"
                                :bindData.sync="queryParam.pshr0001" class="itemShortStyle"
                                show-keys="2000,2300,2400,2500,2800,2900,3100,3200,3250,3300,3400,3500,3600,3700"
                                clearable/>
                </Form-item>
                <Form-item label="是否可设置例外:">
                    <dictSelect :sel_val='queryParam.pshr0012' dictCode="yesorno"
                                :bindData.sync="queryParam.pshr0012"
                                class="itemShortStyle" clearable/>
                </Form-item>
                <Form-item label="办理状态:">
                    <Select v-model="queryParam.state" class="itemShortStyle" clearable>
                        <Option value="1">已办理</Option>
                        <Option value="0">未办理</Option>
                    </Select>
                </Form-item>
                <Form-item label="">
                    <Button type="primary" style="float: right;margin-left: 10px" @click="searchReset">重置
                    </Button>
                    <Button type="primary" style="float: right" @click="searchQuery">查询</Button>
                </Form-item>

            </Form>
            <vxe-table border
                       resizable
                       stripe
                       row-id="id"
                       :row-key="true"
                       show-overflow="tooltip"
                       highlight-hover-row
                       align="center"
                       header-align="center"
                       ref="xTree"
                       :loading="Loading"
                       :data="tableData">
                <vxe-table-column field="azcp0003" title="姓名 " align="center" width="120" fixed="left"/>
                <vxe-table-column field="azcp0001" title="证件号码" align="center" width="180" />
                <vxe-table-column field="pshr0001_name" title="异常类型" align="center" width="200" fixed="left"/>
                <vxe-table-column field="pshr0005_name" title="属地区划" align="center" width="220"/>
                <vxe-table-column field="pshr0002" title="异常详情" align="center" width="220"/>
                <vxe-table-column field="pshr0013" title="死亡时间" align="center" width="120" :formatter="renderTime"/>
                <vxe-table-column field="pshr0003" title="查验时间" align="center" width="120" :formatter="renderTime"/>
                <vxe-table-column field="pshr0008" title="处理人" align="center" width="120"/>
                <vxe-table-column field="pshr0009" title="处理时间" align="center" width="120" :formatter="renderTime"/>
                <vxe-table-column field="pshr0006_name" title="例外类型" align="center" width="180"/>
                <vxe-table-column field="pshr0007" title="例外原因" align="center" width="220"/>
                <vxe-table-column title="操作" align="center" width="140" fixed="right">
                    <template #default="{row}">
                        <span v-if="row.pshr0006==null||row.pshr0006==''">
                            <Button type="error" :disabled="row.pshr0012=='1'?false:true" size="small"
                                    v-if="row.pshr0014=='1'&&row.pshr0012=='1'"
                                    style="margin-right: 5px"
                                    @click="editError(row)"
                                    title="当前查验异常可设置例外处理">设置例外
                            </Button>
                            <Button type="error" :disabled="row.pshr0012=='1'?false:true" size="small"
                                    v-if="row.pshr0014=='1'&&row.pshr0012=='0'"
                                    style="margin-right: 5px"
                                    @click="editError(row)"
                                    title="当前查验异常不可设置例外处理，请去预警处置功能处理">设置例外
                            </Button>
                            <Button type="warning" size="small"
                                    v-if="row.pshr0014=='0'"
                                    style="margin-right: 5px"
                                    @click="editError(row)">设置例外
                            </Button>
                        </span>
                    </template>
                </vxe-table-column>
            </vxe-table>
            <Page :total="dataCount" :page-size="pageSize" show-total class="paging"
                  @on-change="handleTableChange" :current="pageNo"></Page>
        </div>
        <div slot="footer">
            <Button type="text" size="large" @click="visible = false">关闭</Button>
        </div>
        <exception-deal ref="exceptionDeal" @refreshPageData="searchReset"/>
    </Modal>
</template>

<script>
  import { CommonMixin } from '@/views/common/js/CommonMixin'
  import dictSelect from '@/components/dictSelect/dictSelect.vue'
  import DateFormat from '@/plugins/format.js'
  import exceptionDeal from './exceptionDealModel'

  export default {
    mixins: [CommonMixin],
    name: 'exception-handle',
    components: {
      exceptionDeal,
      dictSelect,
    },
    data () {
      return {
        visible: false,
        title: '查验异常信息处理',
        key: '',
        Loading: false,
        queryParam: {},
        ss18900Id: '',
        url: {
          list: '/api/ac/subsistence/ss00005Service/handleValidateList'
        },
      }
    },
    methods: {
      edit (row) {
        this.ss18900Id = row.id
        this.queryParam = {}
        this.queryParam.ss18900Id = row.id
        this.loadData(1)
        this.visible = true
      },
      searchReset () {
        this.queryParam = {}
        this.queryParam.ss18900Id = this.ss18900Id
        this.loadData(1);
        this.$parent.loadData(1);
      },
      cancel () {
        this.queryParam = {}
        this.visible = false
      },
      //查验例外设置
      editError(row) {
        this.$refs.exceptionDeal.edit(row);
        this.$refs.exceptionDeal.key = this.uuid();
      },
    },
  }
</script>

<style scoped>
    /deep/ .ivu-form-item-error-tip {
        display: none;
    }

    .itemStyle {
        width: 300px
    }

    .itemShortStyle {
        width: 180px
    }
</style>
